package cn.class2.demo6

import scala.util.Random

/**
  * Created by lzd on 2018/11/14.
  *
  * 样例类匹配
  */

case class D1(val name: String, val age: Int, val money: Double)

case class D2(val name: String, val age: Int)

case object D3

object Demo6 {
  def main(args: Array[String]): Unit = {
    val arr = Array(new D1("hello", 12, 2.0), new D2("spark", 13), D3)
    arr(Random.nextInt(arr.length)) match {
      case D1(a, b, c) => {
        println(s"$a-$b-$c")
      }
      case D2(a, b) => println(s"$a-$b")
      case D3 => {
        println("d3...")
      }
    }
  }
}
